﻿Imports MiningTool.My.Resources
Imports MiningTool.Org.Mentalis.Files
Imports System.Net
Imports System.IO

Public Class Form1
    Public Shared RUNNING_PATH As String = My.Application.Info.DirectoryPath
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim isAvailable = My.Computer.Network.IsAvailable
        If isAvailable = True Then
            Dim request As HttpWebRequest = DirectCast(WebRequest.Create("http://eve.vigaming.de/tool-status.php"), HttpWebRequest) 'in dieser Zeile deine URL angeben
            request.ServicePoint.Expect100Continue = False
            request.Timeout = 30000
            Dim response As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse)
            Dim reader As StreamReader = New StreamReader(response.GetResponseStream())
            Dim is_answer As String = reader.ReadToEnd()
            If Not response Is Nothing Then response.Close()
            If is_answer = "OKAY" Then
            Else
            End If
        End If
        Dim ini As New IniReader(RUNNING_PATH & "\config.ini")
        ini.Section = "MAIN"
        Dim its_lang As String = ini.ReadString("LANG").ToString()
        ini.Section = "LANG-" & its_lang
        Label1.Text = ini.ReadString("TEXT-01")
        Label2.Text = ini.ReadString("TEXT-02")
        Label3.Text = ini.ReadString("TEXT-03")
        Label4.Text = ini.ReadString("TEXT-04")
        Label5.Text = ini.ReadString("TEXT-05")
        Label6.Text = ini.ReadString("TEXT-06")
        la07.Text = ini.ReadString("TEXT-07")
        la08.Text = ini.ReadString("TEXT-08")
        la09.Text = ini.ReadString("TEXT-09")
        la10.Text = ini.ReadString("TEXT-10")
        la11.Text = ini.ReadString("TEXT-11")
        la12.Text = ini.ReadString("TEXT-12")
        Label9.Text = ini.ReadString("TEXT-13")
        Label12.Text = ini.ReadString("TEXT-13")
        Label16.Text = ini.ReadString("TEXT-13")
        Label17.Text = ini.ReadString("TEXT-13")
        Label18.Text = ini.ReadString("TEXT-13")
        Label11.Text = ini.ReadString("TEXT-14")
        Label7.Text = ini.ReadString("TEXT-15")
    End Sub

    Private Sub anzahl_laser_KeyUp(sender As Object, e As KeyEventArgs) Handles anzahl_laser.KeyUp
        ziel_ertrag_zyklus.Text = ""
        ziel_ertrag_stunde.Text = ""
        ziel_ertrag_tag.Text = ""
        ziel_frachtraum.Text = ""
        ziel_transportzeit.Text = ""
        ziel_gesamt.Text = ""
        Dim Format_Frachtraum As Integer
        Dim Format_Transportzeit As Integer
        Dim Format_Gesamt As Integer
        If anzahl_laser.Text = Nothing Or ertrag_laser.Text = Nothing Or zeit_zyklus.Text = Nothing Or frachtraum.Text = Nothing Or miningzeit.Text = Nothing Or transportzeit.Text = Nothing Then
        Else
            ziel_ertrag_zyklus.Text = ertrag_laser.Text * anzahl_laser.Text
            ziel_ertrag_stunde.Text = 60 / zeit_zyklus.Text * ziel_ertrag_zyklus.Text
            ziel_ertrag_tag.Text = ziel_ertrag_stunde.Text * 24
            ziel_frachtraum.Text = (frachtraum.Text / ziel_ertrag_zyklus.Text) * zeit_zyklus.Text
            ziel_transportzeit.Text = ziel_ertrag_stunde.Text * miningzeit.Text / frachtraum.Text * 2 * transportzeit.Text
            ziel_gesamt.Text = miningzeit.Text * 60 + ziel_transportzeit.Text
            Format_Frachtraum = (frachtraum.Text.ToString() / ziel_ertrag_zyklus.Text.ToString()) * (zeit_zyklus.Text.ToString())
            Format_Transportzeit = ziel_ertrag_stunde.Text.ToString() * miningzeit.Text.ToString() / frachtraum.Text.ToString() * 2 * transportzeit.Text.ToString()
            Format_Gesamt = miningzeit.Text.ToString() * 60 + ziel_transportzeit.Text.ToString()
            ziel_frachtraum.Text = Math.Round(Format_Frachtraum, 4)
            ziel_transportzeit.Text = Math.Round(Format_Transportzeit, 4)
            ziel_gesamt.Text = Math.Round(Format_Gesamt, 4)
        End If
        Me.Refresh()
    End Sub

    Private Sub ertrag_laser_KeyUp(sender As Object, e As KeyEventArgs) Handles ertrag_laser.KeyUp
        ziel_ertrag_zyklus.Text = ""
        ziel_ertrag_stunde.Text = ""
        ziel_ertrag_tag.Text = ""
        ziel_frachtraum.Text = ""
        ziel_transportzeit.Text = ""
        ziel_gesamt.Text = ""
        Dim Format_Frachtraum As Integer
        Dim Format_Transportzeit As Integer
        Dim Format_Gesamt As Integer
        If anzahl_laser.Text = Nothing Or ertrag_laser.Text = Nothing Or zeit_zyklus.Text = Nothing Or frachtraum.Text = Nothing Or miningzeit.Text = Nothing Or transportzeit.Text = Nothing Then
        Else
            ziel_ertrag_zyklus.Text = ertrag_laser.Text * anzahl_laser.Text
            ziel_ertrag_stunde.Text = 60 / zeit_zyklus.Text * ziel_ertrag_zyklus.Text
            ziel_ertrag_tag.Text = ziel_ertrag_stunde.Text * 24
            ziel_frachtraum.Text = (frachtraum.Text / ziel_ertrag_zyklus.Text) * zeit_zyklus.Text
            ziel_transportzeit.Text = ziel_ertrag_stunde.Text * miningzeit.Text / frachtraum.Text * 2 * transportzeit.Text
            ziel_gesamt.Text = miningzeit.Text * 60 + ziel_transportzeit.Text
            Format_Frachtraum = (frachtraum.Text.ToString() / ziel_ertrag_zyklus.Text.ToString()) * (zeit_zyklus.Text.ToString())
            Format_Transportzeit = ziel_ertrag_stunde.Text.ToString() * miningzeit.Text.ToString() / frachtraum.Text.ToString() * 2 * transportzeit.Text.ToString()
            Format_Gesamt = miningzeit.Text.ToString() * 60 + ziel_transportzeit.Text.ToString()
            ziel_frachtraum.Text = Math.Round(Format_Frachtraum, 4)
            ziel_transportzeit.Text = Math.Round(Format_Transportzeit, 4)
            ziel_gesamt.Text = Math.Round(Format_Gesamt, 4)
        End If
        Me.Refresh()
    End Sub

    Private Sub zeit_zyklus_KeyUp(sender As Object, e As KeyEventArgs) Handles zeit_zyklus.KeyUp
        ziel_ertrag_zyklus.Text = ""
        ziel_ertrag_stunde.Text = ""
        ziel_ertrag_tag.Text = ""
        ziel_frachtraum.Text = ""
        ziel_transportzeit.Text = ""
        ziel_gesamt.Text = ""
        Dim Format_Frachtraum As Integer
        Dim Format_Transportzeit As Integer
        Dim Format_Gesamt As Integer
        If anzahl_laser.Text = Nothing Or ertrag_laser.Text = Nothing Or zeit_zyklus.Text = Nothing Or frachtraum.Text = Nothing Or miningzeit.Text = Nothing Or transportzeit.Text = Nothing Then
        Else
            ziel_ertrag_zyklus.Text = ertrag_laser.Text * anzahl_laser.Text
            ziel_ertrag_stunde.Text = 60 / zeit_zyklus.Text * ziel_ertrag_zyklus.Text
            ziel_ertrag_tag.Text = ziel_ertrag_stunde.Text * 24
            ziel_frachtraum.Text = (frachtraum.Text / ziel_ertrag_zyklus.Text) * zeit_zyklus.Text
            ziel_transportzeit.Text = ziel_ertrag_stunde.Text * miningzeit.Text / frachtraum.Text * 2 * transportzeit.Text
            ziel_gesamt.Text = miningzeit.Text * 60 + ziel_transportzeit.Text
            Format_Frachtraum = (frachtraum.Text.ToString() / ziel_ertrag_zyklus.Text.ToString()) * (zeit_zyklus.Text.ToString())
            Format_Transportzeit = ziel_ertrag_stunde.Text.ToString() * miningzeit.Text.ToString() / frachtraum.Text.ToString() * 2 * transportzeit.Text.ToString()
            Format_Gesamt = miningzeit.Text.ToString() * 60 + ziel_transportzeit.Text.ToString()
            ziel_frachtraum.Text = Math.Round(Format_Frachtraum, 4)
            ziel_transportzeit.Text = Math.Round(Format_Transportzeit, 4)
            ziel_gesamt.Text = Math.Round(Format_Gesamt, 4)
        End If
        Me.Refresh()
    End Sub

    Private Sub frachtraum_KeyUp(sender As Object, e As KeyEventArgs) Handles frachtraum.KeyUp
        ziel_ertrag_zyklus.Text = ""
        ziel_ertrag_stunde.Text = ""
        ziel_ertrag_tag.Text = ""
        ziel_frachtraum.Text = ""
        ziel_transportzeit.Text = ""
        ziel_gesamt.Text = ""
        Dim Format_Frachtraum As Integer
        Dim Format_Transportzeit As Integer
        Dim Format_Gesamt As Integer
        If anzahl_laser.Text = Nothing Or ertrag_laser.Text = Nothing Or zeit_zyklus.Text = Nothing Or frachtraum.Text = Nothing Or miningzeit.Text = Nothing Or transportzeit.Text = Nothing Then
        Else
            ziel_ertrag_zyklus.Text = ertrag_laser.Text * anzahl_laser.Text
            ziel_ertrag_stunde.Text = 60 / zeit_zyklus.Text * ziel_ertrag_zyklus.Text
            ziel_ertrag_tag.Text = ziel_ertrag_stunde.Text * 24
            ziel_frachtraum.Text = (frachtraum.Text / ziel_ertrag_zyklus.Text) * zeit_zyklus.Text
            ziel_transportzeit.Text = ziel_ertrag_stunde.Text * miningzeit.Text / frachtraum.Text * 2 * transportzeit.Text
            ziel_gesamt.Text = miningzeit.Text * 60 + ziel_transportzeit.Text
            Format_Frachtraum = (frachtraum.Text.ToString() / ziel_ertrag_zyklus.Text.ToString()) * (zeit_zyklus.Text.ToString())
            Format_Transportzeit = ziel_ertrag_stunde.Text.ToString() * miningzeit.Text.ToString() / frachtraum.Text.ToString() * 2 * transportzeit.Text.ToString()
            Format_Gesamt = miningzeit.Text.ToString() * 60 + ziel_transportzeit.Text.ToString()
            ziel_frachtraum.Text = Math.Round(Format_Frachtraum, 4)
            ziel_transportzeit.Text = Math.Round(Format_Transportzeit, 4)
            ziel_gesamt.Text = Math.Round(Format_Gesamt, 4)
        End If
        Me.Refresh()
    End Sub

    Private Sub miningzeit_KeyUp(sender As Object, e As KeyEventArgs) Handles miningzeit.KeyUp
        ziel_ertrag_zyklus.Text = ""
        ziel_ertrag_stunde.Text = ""
        ziel_ertrag_tag.Text = ""
        ziel_frachtraum.Text = ""
        ziel_transportzeit.Text = ""
        ziel_gesamt.Text = ""
        Dim Format_Frachtraum As Integer
        Dim Format_Transportzeit As Integer
        Dim Format_Gesamt As Integer
        If anzahl_laser.Text = Nothing Or ertrag_laser.Text = Nothing Or zeit_zyklus.Text = Nothing Or frachtraum.Text = Nothing Or miningzeit.Text = Nothing Or transportzeit.Text = Nothing Then
        Else
            ziel_ertrag_zyklus.Text = ertrag_laser.Text * anzahl_laser.Text
            ziel_ertrag_stunde.Text = 60 / zeit_zyklus.Text * ziel_ertrag_zyklus.Text
            ziel_ertrag_tag.Text = ziel_ertrag_stunde.Text * 24
            ziel_frachtraum.Text = (frachtraum.Text / ziel_ertrag_zyklus.Text) * zeit_zyklus.Text
            ziel_transportzeit.Text = ziel_ertrag_stunde.Text * miningzeit.Text / frachtraum.Text * 2 * transportzeit.Text
            ziel_gesamt.Text = miningzeit.Text * 60 + ziel_transportzeit.Text
            Format_Frachtraum = (frachtraum.Text.ToString() / ziel_ertrag_zyklus.Text.ToString()) * (zeit_zyklus.Text.ToString())
            Format_Transportzeit = ziel_ertrag_stunde.Text.ToString() * miningzeit.Text.ToString() / frachtraum.Text.ToString() * 2 * transportzeit.Text.ToString()
            Format_Gesamt = miningzeit.Text.ToString() * 60 + ziel_transportzeit.Text.ToString()
            ziel_frachtraum.Text = Math.Round(Format_Frachtraum, 4)
            ziel_transportzeit.Text = Math.Round(Format_Transportzeit, 4)
            ziel_gesamt.Text = Math.Round(Format_Gesamt, 4)
        End If
        Me.Refresh()
    End Sub

    Private Sub transportzeit_KeyUp(sender As Object, e As KeyEventArgs) Handles transportzeit.KeyUp
        ziel_ertrag_zyklus.Text = ""
        ziel_ertrag_stunde.Text = ""
        ziel_ertrag_tag.Text = ""
        ziel_frachtraum.Text = ""
        ziel_transportzeit.Text = ""
        ziel_gesamt.Text = ""
        Dim Format_Frachtraum As Integer
        Dim Format_Transportzeit As Integer
        Dim Format_Gesamt As Integer
        If anzahl_laser.Text = Nothing Or ertrag_laser.Text = Nothing Or zeit_zyklus.Text = Nothing Or frachtraum.Text = Nothing Or miningzeit.Text = Nothing Or transportzeit.Text = Nothing Then
        Else
            ziel_ertrag_zyklus.Text = ertrag_laser.Text * anzahl_laser.Text
            ziel_ertrag_stunde.Text = 60 / zeit_zyklus.Text * ziel_ertrag_zyklus.Text
            ziel_ertrag_tag.Text = ziel_ertrag_stunde.Text * 24
            ziel_frachtraum.Text = (frachtraum.Text / ziel_ertrag_zyklus.Text) * zeit_zyklus.Text
            ziel_transportzeit.Text = ziel_ertrag_stunde.Text * miningzeit.Text / frachtraum.Text * 2 * transportzeit.Text
            ziel_gesamt.Text = miningzeit.Text * 60 + ziel_transportzeit.Text
            Format_Frachtraum = (frachtraum.Text.ToString() / ziel_ertrag_zyklus.Text.ToString()) * (zeit_zyklus.Text.ToString())
            Format_Transportzeit = ziel_ertrag_stunde.Text.ToString() * miningzeit.Text.ToString() / frachtraum.Text.ToString() * 2 * transportzeit.Text.ToString()
            Format_Gesamt = miningzeit.Text.ToString() * 60 + ziel_transportzeit.Text.ToString()
            ziel_frachtraum.Text = Math.Round(Format_Frachtraum, 4)
            ziel_transportzeit.Text = Math.Round(Format_Transportzeit, 4)
            ziel_gesamt.Text = Math.Round(Format_Gesamt, 4)
        End If
        Me.Refresh()
    End Sub

    Private Sub anzahl_laser_KeyPress(sender As Object, e As KeyPressEventArgs) Handles anzahl_laser.KeyPress
        With anzahl_laser
            Select Case Asc(e.KeyChar)
                Case 44, 46
                    If InStr(.Text, ",") < 1 Then
                        If .TextLength = 0 Or .SelectionLength = .TextLength Then
                            If .SelectionLength > 0 Then .Text = ""
                            .AppendText("0,")
                            e.Handled = True
                        End If
                    Else
                        e.Handled = True
                    End If
                Case 48 To 57, 8
                Case Else
                    e.Handled = True
            End Select
        End With
    End Sub

    Private Sub ertrag_laser_KeyPress(sender As Object, e As KeyPressEventArgs) Handles ertrag_laser.KeyPress
        With ertrag_laser
            Select Case Asc(e.KeyChar)
                Case 44, 46
                    If InStr(.Text, ",") < 1 Then
                        If .TextLength = 0 Or .SelectionLength = .TextLength Then
                            If .SelectionLength > 0 Then .Text = ""
                            .AppendText("0,")
                            e.Handled = True
                        End If
                    Else
                        e.Handled = True
                    End If
                Case 48 To 57, 8
                Case Else
                    e.Handled = True
            End Select
        End With
    End Sub

    Private Sub zeit_zyklus_KeyPress(sender As Object, e As KeyPressEventArgs) Handles zeit_zyklus.KeyPress
        With zeit_zyklus
            Select Case Asc(e.KeyChar)
                Case 44, 46
                    If InStr(.Text, ",") < 1 Then
                        If .TextLength = 0 Or .SelectionLength = .TextLength Then
                            If .SelectionLength > 0 Then .Text = ""
                            .AppendText("0,")
                            e.Handled = True
                        End If
                    Else
                        e.Handled = True
                    End If
                Case 48 To 57, 8
                Case Else
                    e.Handled = True
            End Select
        End With
    End Sub

    Private Sub frachtraum_KeyPress(sender As Object, e As KeyPressEventArgs) Handles frachtraum.KeyPress
        With frachtraum
            Select Case Asc(e.KeyChar)
                Case 44, 46
                    If InStr(.Text, ",") < 1 Then
                        If .TextLength = 0 Or .SelectionLength = .TextLength Then
                            If .SelectionLength > 0 Then .Text = ""
                            .AppendText("0,")
                            e.Handled = True
                        End If
                    Else
                        e.Handled = True
                    End If
                Case 48 To 57, 8
                Case Else
                    e.Handled = True
            End Select
        End With
    End Sub

    Private Sub miningzeit_KeyPress(sender As Object, e As KeyPressEventArgs) Handles miningzeit.KeyPress
        With miningzeit
            Select Case Asc(e.KeyChar)
                Case 44, 46
                    If InStr(.Text, ",") < 1 Then
                        If .TextLength = 0 Or .SelectionLength = .TextLength Then
                            If .SelectionLength > 0 Then .Text = ""
                            .AppendText("0,")
                            e.Handled = True
                        End If
                    Else
                        e.Handled = True
                    End If
                Case 48 To 57, 8
                Case Else
                    e.Handled = True
            End Select
        End With
    End Sub

    Private Sub transportzeit_KeyPress(sender As Object, e As KeyPressEventArgs) Handles transportzeit.KeyPress
        With transportzeit
            Select Case Asc(e.KeyChar)
                Case 44, 46
                    If InStr(.Text, ",") < 1 Then
                        If .TextLength = 0 Or .SelectionLength = .TextLength Then
                            If .SelectionLength > 0 Then .Text = ""
                            .AppendText("0,")
                            e.Handled = True
                        End If
                    Else
                        e.Handled = True
                    End If
                Case 48 To 57, 8
                Case Else
                    e.Handled = True
            End Select
        End With
    End Sub

    Private Sub Button1_MouseClick(sender As Object, e As MouseEventArgs) Handles Button1.MouseClick
        Process.Start("http://eve.vigaming.de")
    End Sub

    Private Sub OptionenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles OptionenToolStripMenuItem.Click
        options.Show()
        Me.Close()
    End Sub

    Private Sub SchliessenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SchliessenToolStripMenuItem.Click
        Me.Close()
    End Sub
End Class
